const mysql = require('mysql')
module.exports = {
    f_DBConnection(resp, sql, arr, callback) {

        let dbconnect = mysql.createConnection({
            host: 'localhost', port: '3306', user: 'root', password: '123456', database: 'demo'
        })
        dbconnect.connect()
        dbconnect.query(sql, arr, function (err, data) {

            if (!err) {
                callback(data)
            } else {
                resp.send(({
                    code: 500,
                    msg: '连接数据库报错,操作失败'
                }))
            }
        })
        dbconnect.end()
    }
}